<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Wechat;
use App\Http\Controllers\ScoreRuleController;
use App\Http\Controllers\JwtController;
use App\Http\Controllers\VideoPlayController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//网站web端接口

Route::get('wechat/auth/index', [Wechat\WechatAuthController::class, 'index_info']); // 微信确认登陆后接受,获取信息
Route::get('wechat/auth/appletIndex', [Wechat\AppletAuthController::class, 'appletIndexInfo']); // 微信确认登陆后接受,获取信息 - 小程序授权   不能用 post  和 any，否则前端即使用 get，也会预请求，造成 code 重复使用
Route::get('wechat/auth/appletTelIndexInfo', [Wechat\AppletAuthController::class, 'appletTelIndexInfo']); // 微信小程序授权获取电话号码后，立即登录
Route::get('wechat/service/createParam', [Wechat\ServiceController::class, 'createParam']); // 获取微信分享需要参数
Route::get('/scoreRule/list', [ScoreRuleController::class, 'lists'])->withoutMiddleware('jwt'); //积分规则,因为微信也要使用，所以排除
Route::get('/scoreRule/customScoreRule', [ScoreRuleController::class, 'customScoreRule'])->withoutMiddleware('jwt'); //获取自定义积分规则,因为微信也要使用，所以排除

Route::post('/getToken', [JwtController::class, 'getAuthToken'])->withoutMiddleware('jwt'); //获取token,->withoutMiddleware([CheckJwtHeaderToken::class])排除这个中间件，因为在路由服务中间件中，自动运用了这个中间件



Route::get('videoPlay/play', [VideoPlayController::class, 'play'])->withoutMiddleware('jwt'); // 播放视频资源接口


//不需要token
Route::prefix('wechat')->group(function () {



    //首页接口
    Route::get('/index/getActivityCalendar', [Wechat\IndexController::class, 'getActivityCalendar']); //官网首页根据时间获取活动


    //数字资源管理
    Route::get('/digital/typeList', [Wechat\DigitalController::class, 'typeList']); //数字资源类型
    Route::get('/digital/list', [Wechat\DigitalController::class, 'lists']); //列表
    Route::post('/digital/addBrowseNum', [Wechat\DigitalController::class, 'addBrowseNum']); //数字资源添加浏览量


    /**
     * 绑定读者证
     */
    Route::post('/userInfo/bingReaderId', [Wechat\UserInfoController::class, 'bingReaderId']); // 绑定读者证


    /**
     * 数字资源(对接外部资源)
     */
    Route::get('/resourceTotal/typeList', [Wechat\ResourceTotalController::class, 'typeList']); // 资源类型 (系统大类)
    Route::get('/resourceTotal/getCustomTypeResourceLists', [Wechat\ResourceTotalController::class, 'getCustomTypeResourceLists']); // 根据自定义类型获取资源列表
    Route::get('/resourceTotal/list', [Wechat\ResourceTotalController::class, 'lists']); // 根据资源类型获取资源列表
    Route::get('/resourceTotal/getZwzxBookCatalogue', [Wechat\ResourceTotalController::class, 'getZwzxBookCatalogue']); // 获取中文在线图书目录
    Route::get('/resourceTotal/getYtysBookCatalogue', [Wechat\ResourceTotalController::class, 'getYtysBookCatalogue']); // 获取云图有声图书目录

    Route::get('/resourceTotalSearch/resourceSearch', [Wechat\ResourceTotalSearchController::class, 'resourceSearch']); // 检索资源
    Route::get('/resourceTotalSearch/resourceList', [Wechat\ResourceTotalSearchController::class, 'resourceList']); // 检索资源（根据类型检索）（除汇画外的资源检索）
    Route::get('/resourceTotalSearch/resourcePicturesList', [Wechat\ResourceTotalSearchController::class, 'resourcePicturesList']); // 检索资源（根据类型检索）（只检索汇画资源）
    Route::get('/resourceTotalSearch/hotSearchList', [Wechat\ResourceTotalSearchController::class, 'hotSearchList']); // 检索热词列表


    /**
     * 数字资源(各种展示数据)
     */
    Route::get('/resourceTotalData/getResourceExternalTypeList', [Wechat\ResourceTotalDataController::class, 'getResourceExternalTypeList']); // 获取外部类型列表
    Route::get('/resourceTotalData/getResourceBusinessList', [Wechat\ResourceTotalDataController::class, 'getResourceBusinessList']); // 获取资源商列表
    Route::get('/resourceTotalData/getResourceBusinessBookList', [Wechat\ResourceTotalDataController::class, 'getResourceBusinessBookList']); // 根据资源商id获取书籍列表
    Route::get('/resourceTotalData/getReadBookRank', [Wechat\ResourceTotalDataController::class, 'getReadBookRank']); // 获取阅读榜单



    /**
     * 推荐书单列表
     */
    Route::get('/resourceReadingList/getReadingList', [Wechat\ResourceReadingListController::class, 'getReadingList']); // 获取推荐书单列表
    Route::get('/resourceReadingList/getReadingDetail', [Wechat\ResourceReadingListController::class, 'getReadingDetail']); // 获取书单详情
    Route::get('/resourceReadingList/getReadingBookList', [Wechat\ResourceReadingListController::class, 'getReadingBookList']); // 根据书单id获取书籍列表

    /**
     * 推荐阅读（书单形式数据）书籍列表
     */
    Route::get('/resourceReadRecom/getResourceReadRecomList', [Wechat\ResourceReadRecomController::class, 'getResourceReadRecomList']); // 获取推荐阅读（书单形式数据）书籍列表
    Route::get('/resourceReadRecom/getResourceReadRecomDetail', [Wechat\ResourceReadRecomController::class, 'getResourceReadRecomDetail']); // 获取推荐阅读（书单形式数据）详情
    Route::get('/resourceReadRecom/getResourceReadRecomBookList', [Wechat\ResourceReadRecomController::class, 'getResourceReadRecomBookList']); // 获取推荐阅读（书单形式数据）书籍列表


    /**
     * 获取系统栏目列表
     */
    Route::get('/resourceSystemList/getSystemTypeList', [Wechat\ResourceSystemListController::class, 'getSystemTypeList']); // 获取系统栏目列表
    Route::get('/resourceSystemList/getSystemTypeBookList', [Wechat\ResourceSystemListController::class, 'getSystemTypeBookList']); // 根据系统栏目id获取书籍列表 （只对 way为 1,3,4有效，对于2的直接获取书单列表）

});

//token必选
Route::middleware(['check.wechat.token'])->prefix('wechat')->group(function () {




    //修改头像 和 昵称
    Route::post('/userInfo/wechatInfoChange', [Wechat\UserInfoController::class, 'wechatInfoChange']); //修改头像 和 昵称


    //用户留言管理
    Route::post('/feedback/add', [Wechat\FeedbackController::class, 'addFeedback']); //用户留言


    /*用户获取消息列表*/
    Route::get('/system/systemList', [Wechat\SystemInfoController::class, 'systemList']); // 列表
    Route::get('/system/systemMessage', [Wechat\SystemInfoController::class, 'systemMessage']); //获取用户分类消息列表




    /**
     * 个人中心
     */
    Route::get('/userInfo/scoreList', [Wechat\UserInfoController::class, 'scoreList']); // 获取用户积分明细
    Route::get('/userInfo/index', [Wechat\UserInfoController::class, 'index']); // 个人中心首页
    Route::get('/userInfo/getUserReadDuration', [Wechat\UserInfoController::class, 'getUserReadDuration']); // 获取用户阅读浏览量


    /**
     * 数字资源(对接外部资源)
     */
    Route::post('/resourceTotal/collectAndCancel', [Wechat\ResourceTotalController::class, 'collectAndCancel']); // 资源收藏与取消收藏
    Route::get('/resourceTotal/myCollectTypeList', [Wechat\ResourceTotalController::class, 'myCollectTypeList']); // 我的资源收藏类型列表
    Route::get('/resourceTotal/myCollectList', [Wechat\ResourceTotalController::class, 'myCollectList']); // 我的资源收藏列表
    Route::get('/resourceTotal/getZwzxSingleSign', [Wechat\ResourceTotalController::class, 'getZwzxSingleSign']); // 获取中文在线单点登录信息
    Route::get('/resourceTotal/getYtysChapterAudioAddress', [Wechat\ResourceTotalController::class, 'getYtysChapterAudioAddress']); // 获取云图有声章节音频地址


    /**
     * 数字资源(各种展示数据)
     */
    Route::get('/resourceTotalData/getUserReadBookHistory', [Wechat\ResourceTotalDataController::class, 'getUserReadBookHistory']); // 获取用户历史阅读
    Route::post('/resourceTotalData/addReadDuration', [Wechat\ResourceTotalDataController::class, 'addReadDuration']); // 添加用户阅读时长记录


    /**
     * 用户访问资源信息
     */
    Route::get('/resourceAccessUser/list', [Wechat\ResourceAccessUserController::class, 'lists']); // 列表
    Route::post('/resourceAccessUser/del', [Wechat\ResourceAccessUserController::class, 'del']); // 删除用户访问记录

});

//token可选
Route::middleware(['check.may.wechat.token'])->prefix('wechat')->group(function () {

    //首页接口
    Route::get('/index/index', [Wechat\IndexController::class, 'index']); //首页
    Route::get('/index/getPicturesData', [Wechat\IndexController::class, 'getPicturesData']); //获取汇画首页资源
    Route::get('/index/getActivityData', [Wechat\IndexController::class, 'getActivityData']); //热门活动资源(获取悦读圈活动)



    /**
     * 数字资源(对接外部资源)
     */
    Route::get('/resourceTotal/index', [Wechat\ResourceTotalController::class, 'index']); // 获取首页接口
    Route::get('/resourceTotal/detail', [Wechat\ResourceTotalController::class, 'detail']); // 获取资源详情

});


//必须绑定读者证
Route::middleware(['check.bind.reader.token'])->prefix('wechat')->group(function () {


    Route::post('/libInfo/unBindReaderId', [Wechat\LibInfoController::class, 'unBindReaderId']); // 解除绑定读者证
    Route::post('/libInfo/changePwd', [Wechat\LibInfoController::class, 'changePwd']); // 修改读者证密码
    Route::get('/libInfo/getBorrowList', [Wechat\LibInfoController::class, 'getBorrowList']); // 获取借阅记录列表
    Route::post('/libInfo/renew', [Wechat\LibInfoController::class, 'renewBook']); // 在线续借



    /**
     * 积分签到
     */
    Route::get('/signScore/signScoreInfo', [Wechat\SignScoreController::class, 'signScoreInfo']); // 获取积分签到信息
    Route::post('/signScore/sign', [Wechat\SignScoreController::class, 'sign']); // 用户打卡签到

});
